<span page-title ng-model="branch">{{ 'OSTree Branch: ' | translate }} {{ branch.name }}</span>

<h3 translate>
  Repositories containing branch {{ branch.name }}
</h3>

<div data-extend-template="layouts/partials/table.html">
  <div data-block="search-filter">
    <select class="form-control"
            placeholder="{{ 'Select Environment' | translate }}"
            ng-disabled="!environments"
            ng-model="environmentFilter"
            ng-options="e.id as e.name for e in environments"
            ng-change="filterBranches()">
    </select>

    <select class="form-control"
            placeholder="{{ 'Select Content View' | translate }}"
            ng-disabled="!contentViews || filteredCVs.length === 0"
            ng-model="contentViewFilter"
            ng-options="cv as cv.name for cv in filteredCVs = (contentViews | filter:{environment_ids: environmentFilter})"
            ng-change="filterBranches()">
    </select>
    <p class="help-block" translate ng-show="filteredCVs.length === 0">
      There are no Content Views in this Environment.
    </p>
  </div>

  <span data-block="no-rows-message" translate>
    No Repositories contain this Branch.
  </span>

  <div data-block="table">
    <table class="table table-striped table-bordered" ng-class="{'table-mask': table.working}">
      <thead>
        <tr bst-table-head>
          <th bst-table-column="name"><span translate>Name</span></th>
          <th bst-table-column="product"><span translate>Product</span></th>
          <th bst-table-column="lastSync"><span translate>Last Sync</span></th>
        </tr>
      </thead>

      <tbody>
        <tr bst-table-row
            ng-repeat="repository in table.rows">
          <td bst-table-cell>
            <a ng-href="/products/{{ repository.product.id }}/repositories/{{ repository.library_instance_id || repository.id }}">
              {{ repository.name }}
            </a>
          </td>
          <td bst-table-cell>
            <a ui-sref="product.repositories({productId: repository.product.id})">
              {{ repository.product.name }}
            </a>
          </td>
          <td bst-table-cell>
              <span ng-show="repository.url">
              <span ng-show="repository.last_sync == null" translate>
                Not Synced
              </span>
              <span ng-hide="repository.last_sync == null">
                <a href="/foreman_tasks/tasks/{{repository.last_sync.id}}">{{ repository.last_sync.result | capitalize}}</a>
                <span translate>{{ repository.last_sync_words }} ago</span>
              </span>
            </span>
            <span ng-hide="repository.url" translate>N/A</span>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
